package com.weishu.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.weishu.domain.TCwCheckBatch;
import com.weishu.service.ITCwCheckBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 对账批次Controller
 * 
 * @author ruoyi
 * @date 2023-05-06
 */
@RestController
@RequestMapping("/checkbatch")
public class TCwCheckBatchController extends BaseController
{
    @Autowired
    private ITCwCheckBatchService tCwCheckBatchService;

    /**
     * 查询对账批次列表
     */
    @RequiresPermissions("money:checkbatch:list")
    @GetMapping("/list")
    public TableDataInfo list(TCwCheckBatch tCwCheckBatch)
    {
        startPage();
        List<TCwCheckBatch> list = tCwCheckBatchService.selectTCwCheckBatchList(tCwCheckBatch);
        return getDataTable(list);
    }

    /**
     * 导出对账批次列表
     */
    @RequiresPermissions("money:checkbatch:export")
    @Log(title = "对账批次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCwCheckBatch tCwCheckBatch)
    {
        List<TCwCheckBatch> list = tCwCheckBatchService.selectTCwCheckBatchList(tCwCheckBatch);
        ExcelUtil<TCwCheckBatch> util = new ExcelUtil<TCwCheckBatch>(TCwCheckBatch.class);
        util.exportExcel(response, list, "对账批次数据");
    }

    /**
     * 获取对账批次详细信息
     */
    @RequiresPermissions("money:checkbatch:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tCwCheckBatchService.selectTCwCheckBatchById(id));
    }

    /**
     * 新增对账批次
     */
    @RequiresPermissions("money:checkbatch:add")
    @Log(title = "对账批次", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCwCheckBatch tCwCheckBatch)
    {
        return toAjax(tCwCheckBatchService.insertTCwCheckBatch(tCwCheckBatch));
    }

    /**
     * 修改对账批次
     */
    @RequiresPermissions("money:checkbatch:edit")
    @Log(title = "对账批次", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCwCheckBatch tCwCheckBatch)
    {
        return toAjax(tCwCheckBatchService.updateTCwCheckBatch(tCwCheckBatch));
    }

    /**
     * 删除对账批次
     */
    @RequiresPermissions("money:checkbatch:remove")
    @Log(title = "对账批次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCwCheckBatchService.deleteTCwCheckBatchByIds(ids));
    }


    /**
     * 查询对账批次
     */
    @RequestMapping("/one")
    public TCwCheckBatch one(@RequestBody TCwCheckBatch tCwCheckBatch)
    {
        System.out.println(tCwCheckBatch);
        return tCwCheckBatchService.selectTCwCheckBatchForDate(tCwCheckBatch);
    }

    /**
     * 新增对账批次
     */
    @RequestMapping("scadd")
    public int scadd(@RequestBody TCwCheckBatch tCwCheckBatch)
    {
        return tCwCheckBatchService.insertTCwCheckBatch(tCwCheckBatch);
    }

}
